/***************************************************************************
 *   Copyright (C) 2009 by maarten,,,   *
 *   maarten@maarten-laptop   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef PARSERPARSER_H
#define PARSERPARSER_H

#include <qxml.h>

namespace utils{
    class Vector3D;
}

namespace object{
    class Vertex;
}

namespace scene{
    class SceneManager;
    class SubScene;
    class Shape;
}

namespace parser {

/**
	@author maarten,,, <maarten@maarten-laptop>
*/
class Parser : public QXmlDefaultHandler{

public:
    Parser(scene::SceneManager *sceneMgr = NULL);
    ~Parser();

    bool startDocument();
    bool startElement( const QString&, const QString&, const QString& , 
                       const QXmlAttributes& );
    bool endElement( const QString&, const QString&, const QString& );

private:
    scene::SceneManager *m_sceneMgr;
    
    int m_status; // what are we parsing
    int m_sceneTreeLevel;
    scene::SubScene* m_currentSubScene;
    
    /***************************************************************
    * status = 3 :: GEOMETRY
    ****************************************************************/
    bool parseGeometry(const QString& qName, const QXmlAttributes&
                                                                  attributes);
    
                                                                     
    /***************************************************************
    * status = 4 :: Texture
    ****************************************************************/
    bool parseTexture(const QString& qName, const QXmlAttributes&
                                                                  attributes);
                                                                     
    /***************************************************************
    * status = 5 :: MATERIAL
    ****************************************************************/
    bool parseMaterial(const QString& qName, const QXmlAttributes&
                                                                  attributes);
                                                                  
    /***************************************************************
    * status = -1 :: OTHER
    ****************************************************************/
    bool parseOther(const QString& qName, const QXmlAttributes& attributes);
    
    /***************************************************************
    * status = 6 :: SUBSCENES
    ****************************************************************/
    bool parseSubScenes(const QString& qName, const QXmlAttributes& attributes);
    
    scene::Shape* parseShape(const QXmlAttributes& attributes);

    // submethodes for parsing different sorts of sceneElements
    bool parseCam(QString name = "", QString pos = "", QString dir="", QString
                    up = "", QString fovy = "");
    bool parseLight(QString name= "",
                    QString pos= "", QString intensity= "", QString color= "");
    bool parseSurfaceLight(QString name= "",
                    QString pos= "", QString intensity= "", QString color= "",
QString alpha = "", QString beta = "", QString surfFactor = "");
    bool parseCylinder(QString name, QString radius, QString height, QString
capped );

    bool parseCone(QString name, QString radius, QString height,
                            QString capped);

    bool parseScene(QString camString, QString lights, QString colorString,
QString antiAliasing);

    // help methods for parsing small items
    object::Vertex* parseTuple3(QString tuple);
    bool parseBool(QString boolString);
};

}

#endif
